@extends('admin.layout')
@section('title',$title)
@section('content')
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                文章列表
                
            </h1>
            <ol class="breadcrumb">
                <li><a href="/admin/article"><i class="fa fa-dashboard"></i>文章列表 </a></li>
                </li>
            </ol>
        </section>
        <!-- 文章添加成功 -->
        @if (session('success'))
            <div class="alert alert-success alert-dismissable">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <h4><i class="icon fa fa-check"></i>恭喜!</h4>
                        {{ session('success') }}
            </div>
        @endif
<!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            {{--分页--}}
                            <!-- 搜索文章,和当前页面的数据数 -->
                            <form action="/admin/article/show" method="get">
                            <div class="col-md-2">
                            <div class="form-group">
                                <select name="num" class="form-control">
                                <!-- 判断num的值,并选中 -->
                                    <option
                                    @if(!empty($request['num']) && $request['num'] == 10)
                                        selected
                                    @endif
                                    >10</option>
                                    <option
                                    @if(!empty($request['num']) && $request['num'] == 20)
                                        selected
                                    @endif
                                    >20</option>
                                    <option
                                    @if(!empty($request['num']) && $request['num'] == 50)
                                        selected
                                    @endif
                                    >50</option>
                                    <option
                                    @if(!empty($request['num']) && $request['num'] == 100)
                                        selected
                                    @endif
                                    >100</option>
                                </select>
                            </div>

                            </div>
                            
                       
                            <div class="col-md-3 col-md-offset-7">
                            <div class="input-group input-group-sm">
                                <input name="keywords" type="text" class="form-control" value="{{$request['keywords'] or ''}}">
                                <span class="input-group-btn">
                                  <button class="btn btn-info btn-flat">搜索!</button>
                                </span>
                            </div>
                            </div>
                            </form>
                        </div><!-- /.box-header -->
                        <!-- 文章列表 -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>文章标题</th>
                                    <th>文章图片</th>
                                    <th>发布时间</th>
                                    <th>更新时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($data as $article)
                                <tr>
                                    <td>{{$article -> id}}</td>
                                    <td>{{$article -> title}}</td>
                                    <td><img src="{{$article -> pic}}" width="100"></td>
                                    <td>{{date('Y-m-d',$article -> atime)}}</td>
                                    <td>{{date('Y-m-d',$article -> uptime)}}</td>
                                    <!-- 编辑和删除 -->
                                    <td><a href="/admin/article/{{$article -> id}}/edit/" class="btn btn-block btn-success">编辑</a><br>
                                    <form action="/admin/article/{{$article -> id}}" method="post">
                                        {{ csrf_field() }}
                                        {{ method_field("DELETE") }}
                                        <button class="btn btn-block btn-danger">删除</button>
                                    </form>
                                    </td>
                                </tr>
                                @endforeach
                                </tfoot>
                            </table>
                            {!! $data->appends($request)->render() !!}
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->


                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
@endsection
